package values.shop
{
import core.Language;

/**
 * ShopGroupTypeValue
 * @author jliang
 *
 */
public class ShopGroupTypeValue
{    
    [Data(type="field", mapping="@index")]
    public var index:int;
    
    [Data(type="field", mapping="@name")]
    public var baseNameKey:String;
    
    public function get name():String
    {
        return Language.getText(baseNameKey);
    }
    
    [Data(type="field", mapping="@items")]
    public var itemListDef:String;
    
    private var _itemList:Vector.<ShopItemValue>;

    public function get itemList():Vector.<ShopItemValue>
    {
        if (!_itemList)
        {
            _itemList = new Vector.<ShopItemValue>();
            
            if (itemListDef == null || itemListDef == "") return _itemList;
            
            var items:Array = itemListDef.split(",");
            
            for (var i:int = 0; i < items.length; i ++)
            {
                var sikey:String = items[i];
                _itemList.push(ShopConfigValue.getShopItemByKey(sikey));
            }
        }
        return _itemList;
    }

}
}